//=============================================================================

#include "../../../../inc/aPacketCloseConnection.h"

//=============================================================================

aPacketCloseConnection::aPacketCloseConnection() : aPacket()
{
  type = PAK_CLS_CON;
  apPreparePacket();
}

//=============================================================================

aPacketCloseConnection::aPacketCloseConnection(char* in = 0) : aPacket(in)
{
}

//=============================================================================

aPacketCloseConnection::aPacketCloseConnection(const aPacketCloseConnection& p) : aPacket(p)
{
}

//=============================================================================

void aPacketCloseConnection::apPreparePacket()
{
  apClearPacket();

  size_t step = 0;

  length = 1 + longSize;
  type = PAK_CLS_CON;
  data = new char[length + 1];
  data[step] = type;
  step++;

  memcpy(&data[step], &length, longSize);
  step += longSize;

  data[length] = 0;
}

//=============================================================================

const aPacketCloseConnection& aPacketCloseConnection::operator=(const aPacketCloseConnection& p)
{
  apClearPacket();

  if (p.apGetLength() <= 0)
    return (*this);

  length = p.apGetLength();
  data = new char[length];
  memcpy(data, p.apGetData(), length);
  type = p.apGetType();

  return (*this);
}

//=============================================================================

aPacketCloseConnection::~aPacketCloseConnection()
{
  apClearPacket();
}

//=============================================================================
